<template>
  <view class="container">
    <uni-list>
      <uni-list-item  title="昵称" :rightText="user.nickName" />
      <uni-list-item  title="性别" :rightText="user.sex" />
      <uni-list-item  title="年龄" :rightText="user.userAge" />
      <uni-list-item  title="身高cm" :rightText="user.userHeight" />
	  <uni-list-item  title="体重Kg" :rightText="user.userWeight" />
	  
	  <uni-list-item  title="民族" :rightText="user.userNation" />
	  <uni-list-item  title="毕业院校" :rightText="user.userGradu" />
	  <uni-list-item  title="月收入" :rightText="user.userIncome" />
	  
	  <uni-list-item  title="民族" :rightText="user.userNation" />
	  <uni-list-item  title="毕业院校" :rightText="user.userGradu" />
	  <uni-list-item  title="月收入" :rightText="user.userIncome" />
	  
	  <uni-list-item  title="居住地" :rightText="user.userLocation" />
	  <uni-list-item  title="家乡" :rightText="user.userHome" />
	  <uni-list-item  title="房产情况" :rightText="user.userHouse" />
	  <uni-list-item  title="车产情况" :rightText="user.userCar" />
	  <uni-list-item  title="职业" :rightText="user.vocation" />
	  <uni-list-item  title="学历" :rightText="user.userEdu" />
	  
	  <uni-list-item  title="婚姻状况" :rightText="user.userMarr" />
	  <uni-list-item  title="希望何时结婚" :rightText="user.marrExpect" />
	  <uni-list-item  title="个人说明" :rightText="user.userExplain" />
	  <uni-list-item  title="择偶要求" :rightText="user.userRequire" />
    </uni-list>
	<view class="imgContainer">
	  <view class="grid-item" v-for="(item, index) in imageList" :key="index">
	  	<image :src="item"  @click="clickImg(index)"></image>
	  </view>
	</view>
  </view>

</template>

<script>
  import { getUser } from "@/api/system/user"
  import { listFile } from "@/api/system/file"
  import config from "@/config.js" // 全局配置文件
  export default {
    data() {
      return {
        user: {},
        imageList: [],
      }
    },
    onLoad(options) {
      this.getUser(options.userId);
	  this.getFiles(options.userId);
    },
    methods: {
      getUser(userId) {
        getUser(userId).then(response => {
          this.user = response.data
          
        })
      },
	  getFiles(userId){
	  		let queryParams = {
	  			userId: userId,
	  			pageNum: 1,
	  			pageSize: 10,
	  			orderByColumn: "createTime",
	  			isAsc: "desc",
	  		}
	  		listFile(queryParams).then(response => {
	  			if (response.code === 200) {
	  				let rows = response.rows;
	  				if(rows.length > 0){
	  					let files = rows[0].mediaUrl;
	  					if(files){
	  						let urlList = files.split(",");
	  						for (var i=0;i<urlList.length;i++){
	  							if(urlList[i].length>0){
	  								this.imageList.push(config.baseUrl+urlList[i]);
	  							}
	  						};
	  					}
	  					
	  				}
	  			}
	  		});
	  },
	  clickImg(index) {
	          uni.previewImage({
	            urls: this.imageList, //需要预览的图片http链接列表，多张的时候，url直接写在后面就行了
	            current: index, // 当前显示图片的http链接，默认是第一个
	            success: function(res) {},
	            fail: function(res) {},
	            complete: function(res) {},
	          })
	        },
    }
  }
</script>

<style lang="scss">
  page {
    background-color: #ffffff;
  }
  .imgContainer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    padding: 10px;
    
    .grid-item {
      width: 32.3333%; 
      box-sizing: border-box;
      padding: 5px;
      
      .grid-img {
        width: 100%;
        height: auto;
        display: block;
      }
    }
  }
</style>
